<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset = "UTF-8">
    <title>Title</title>

    <!--=====================================================================-->
    <script>
        //


        window.onload = function () {
            //获取当前页面顶端和现在屏幕顶端之间的距离
            document.onclick = function () {
                console.log(document.documentElement.scrollTop);
                console.log(document.body.scrollTop);               //ie专属,已测试chrome下一直为0
            };


            let oDiv = document.getElementById('div1');

            document.onmousemove = function (ev) {
                if (oDiv.style.display !== 'block') oDiv.style.display = 'block';

                oDiv.style.left = ev.clientX + 'px';        //设置左边距离等于x轴数值
                oDiv.style.top = ev.clientY + + document.documentElement.scrollTop + 'px';  //y轴需要加个scrollTop
            }
        };



    </script>
</head>

<body style="height: 2000px;">

<div>
    <div style="width: 120px;height: 70px;background: salmon;position: absolute;display: none" id="div1">
        <span style="font-size: 55px">傻逼</span>
    </div>

</div>

</body>
</html>